import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import models.UserInfo;

import java.util.ArrayList;
import java.util.List;

public class TestDemo {


    public static void main(String[] args) throws JsonProcessingException {
        ObjectMapper mapper = new ObjectMapper();
        List<UserInfo> list = new ArrayList<>();
        for(int i = 0; i < 3; i++){
            UserInfo userinfo = new UserInfo();
            userinfo.setUsername("java"+i);
            userinfo.setPassword("pwd"+i);
            list.add(userinfo);
        }

        String result = mapper.writeValueAsString(list);
        System.out.println(result);
    }
}
